﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FlowgraphViewer.Model;
using FlowgraphViewer.Services;

namespace FlowgraphViewer.Tests
{
    [TestClass]
    public class XmlParserTest
    {
        [TestMethod]
        public void TestSampleFlowgraph()
        {
            string flowgraphXml = ExampleFlowgraphs.GetSmallFlowgraph();

            Flowgraph fg = FlowgraphXmlParser.GetFlowgraph(flowgraphXml);

            Assert.IsNotNull(fg);

            Assert.IsTrue(fg.Description == "", "Description should be empty");
            Assert.IsTrue(fg.Enabled, "Enabled should be true");
            Assert.IsTrue(fg.Multiplayer == EFlowgraphMultiplayer.ClientServer);

            Assert.IsTrue(fg.Nodes.Count == 3);
            Assert.IsTrue(fg.Nodes[0].Id == 1);
            //Assert.IsTrue(fg.Nodes[0].Inputs);

            Assert.IsNotNull(fg.GetFlowNodeInstanceById(1));
            Assert.IsNotNull(fg.GetFlowNodeInstanceById(1).FlowNode.Name == "Start");
            Assert.IsTrue(fg.Edges.Count == 3);
        }

        [TestMethod]
        public void TestBigFlowgraph()
        {
            string flowgraphXml = ExampleFlowgraphs.GetLargeFlowgraph();

            Flowgraph fg = FlowgraphXmlParser.GetFlowgraph(flowgraphXml);


            Assert.IsNotNull(fg);
        }

        [TestMethod]
        public void TestInvalidFlowgraph()
        {
            string flowgraphXml = ExampleFlowgraphs.GetInvalidFlowgraph();

            Flowgraph fg = FlowgraphXmlParser.GetFlowgraph(flowgraphXml);

            Assert.IsNull(fg);
        }
    }
}
